/**
 * Created by hjqi on 2016/4/19.
 */
angular.module('NatureCloud').factory('monitorService', function ($http) {
   //  通过clsuterId来区分不同的集群环境
    return {
        getMonitorState:function(id){
            var data = {
                id:id
            };
            return $http.post('/apiMonitor/getStatus',data).then(function (response) {
                return response;
            });
        },
        getPodsList:function(id){
            var data = {
                app:id
            };
            return $http.post('/apiMonitor/getPodsList',data).then(function (response) {
                return response;
            });
        },
        getCpuStatusDatas:function(id,interval,limits,clsuterId){
            var data = {
                table:'cpu_usage_total',
                id:id,
                interval:interval,
                limits:limits,
                collector:"heapster",
                clsuterId:clsuterId
            }
            return $http.post('/apiMonitor/getInfluxdbQuery',data).then(function (response) {
                return response;
            });
        },
        getMemStatusDatas:function(id,interval,limits,clsuterId){
            var data = {
                table:'memory_usage',
                id:id,
                interval:interval,
                limits:limits,
                collector:"heapster",
                clsuterId:clsuterId
            }
            return $http.post('/apiMonitor/getInfluxdbQuery',data).then(function (response) {
                return response;
            });
        },
        getNTRxStatusDatas:function(id,interval,limits,clsuterId) {
            var data = {
                table: 'rx_bytes',
                id: id,
                interval: interval,
                limits: limits,
                collector:"heapster",
                clsuterId:clsuterId
            }
            return $http.post('/apiMonitor/getInfluxdbQuery', data).then(function (response) {
                return response;
            });
        },
        getNTTxStatusDatas:function(id,interval,limits,clsuterId) {
            var data = {
                table: 'tx_bytes',
                id: id,
                interval: interval,
                limits: limits,
                collector:"heapster",
                clsuterId:clsuterId
            }
            return $http.post('/apiMonitor/getInfluxdbQuery', data).then(function (response) {
                return response;
            });
        }
    }

});